/**
 * Copyright (c) 2021 Choice, Inc.
 * All Rights Reserved.
 * Choice Proprietary and Confidential.
 */
package cn.ruleengine.web.vo.ruleset;

import java.util.List;
import java.util.Objects;
import java.util.Set;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 条件链
 *
 * @author <a href="mailto:danliang@myweimai.com">丹良</a>
 * @date 2021/7/26
 */
@Getter
@Setter
@ToString
public class ConditionChainResponse {

    private String       title;
    private Set<edge>    edges;
    private List<String> noRules;
    private Set<node>    nodes;

    @Getter
    @Setter
    @ToString
    @AllArgsConstructor
    public static class edge {
        private final String source;
        private final String target;

        public static edge of(String source, String target) {
            return new edge(source, target);
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            edge edge = (edge) o;
            return Objects.equals(source, edge.source) &&
                    Objects.equals(target, edge.target);
        }

        @Override
        public int hashCode() {
            return Objects.hash(source, target);
        }
    }

    @Getter
    @Setter
    @ToString
    @AllArgsConstructor
    public static class node {
        private final String id;
        private final String label;

        public static node of(String id, String label) {
            return new node(id, label);
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            node node = (node) o;
            return Objects.equals(id, node.id);
        }

        @Override
        public int hashCode() {
            return Objects.hash(id);
        }
    }
    /**
     * 案例：
     *
     * {
     * 	"title": "颈动脉超声互认规则",
     * 	"edges": [
     *        {
     * 			"source": 1,
     * 			"target": 3
     *        },
     *        {
     * 			"source": 3,
     * 			"target": 4
     *        },
     *        {
     * 			"source": 4,
     * 			"target": 5
     *        },
     *        {
     * 			"source": 3,
     * 			"target": 2
     *        },
     *        {
     * 			"source": 5,
     * 			"target": 6
     *        }
     * 	],
     * 	"noRules": [
     * 		"因病情变化，已有的检查结果难以反映病人当前实际病情的",
     * 		"因时效问题，已有的检查检验结果难以提供参考价值的",
     * 		"检查检验结果与疾病发展关联程度高、变化幅度大的项目",
     * 		"检查检验结果与病情明显不符的",
     * 		"患者或其亲属要求做进一步检查检验的",
     * 		"重新复查检查检验项目对治疗措施意义重大的（如手术等重大医疗措施前）",
     * 		"因疾病转归需连续对比观察的",
     * 		"急诊、急救等抢救生命的紧急状态下的",
     * 		"司法、伤残及病退等鉴定所需的",
     * 		"其他符合诊疗需要的不可预测情形"
     * 	],
     * 	"nodes": [
     *        {
     * 			"id": 1,
     * 			"label": "颈动脉超声"
     *        },
     *        {
     * 			"id": 2,
     * 			"label": "强制互认"
     *        },
     *        {
     * 			"id": 3,
     * 			"label": "报告时间在3个月内"
     *        },
     *        {
     * 			"id": 4,
     * 			"label": "颈动脉诊断结论正常"
     *        },
     *        {
     * 			"id": 5,
     * 			"label": "颈动脉硬化结论正常"
     *        },
     *        {
     * 			"id": 6,
     * 			"label": "颈动脉硬化结论正常1"
     *        }
     * 	]
     * }
     */
}
